#{include file="../Common/Header.html"}
#{set_script_var([
    "_business_notice_var" => $business.notice
])}
<div class="layui-container fly-marginTop fly-user-main">
    #{include file="../Common/Nav.html"}
    <div class="fly-panel fly-panel-user" pad20>
        <div class="layui-tab layui-tab-brief" lay-filter="user">
            <div class="content-header">
                <i class="layui-icon">&#xe638;</i> 我的店铺
            </div>

            <div class="content-body">
                #{if !$business}
                    <blockquote class="elem-quote">
                        您还没有开通店铺
                    </blockquote>
                #{/if}
                #{if $purchase == 1}
                    <blockquote class="elem-quote">
                        升级您的店铺，享受更多权益
                    </blockquote>
                #{/if}
                #{if !$business || $purchase == 1 && $business}
                    <form class="layui-form" action="">
                        <div class="form-block">
                            <div>
                                <div class="form-header">请选择</div>
                                <div class="form-body">
                                    #{foreach $level as $le}
                                        <a class="button-click business-group" data-id="#{$le.id}"
                                           style="line-height: 22px;color: #db66ac;"> <img
                                                    src="#{$le.icon}" class="pay-icon" style="margin-top: -5px;"> <span
                                                    style="font-weight: bold;">#{$le.name}</span> <span
                                                    style="font-weight: bold;">¥#{$le.price}</span>
                                            <hr>
                                            <div style="font-size: 12px;">
                                                <p>分站功能：#{if $le.substation == 1}<i class="layui-icon"
                                                                                    style="color: green;">&#xe605;</i>
                                                    #{else}<i class="layui-icon" style="color: red;">&#x1006;</i>#{/if}
                                                </p>
                                                <p>分站返佣：<i class="layui-icon" style="color: green;">&#xe605;</i></p>
                                                <p>独立域名：#{if $le.top_domain == 1}<i class="layui-icon"
                                                                                    style="color: green;">&#xe605;</i>
                                                    #{else}<i class="layui-icon" style="color: red;">&#x1006;</i>#{/if}
                                                </p>
                                                <p>供货权限：#{if $le.supplier == 1}<i class="layui-icon"
                                                                                  style="color: green;">&#xe605;</i>
                                                    #{else}<i class="layui-icon" style="color: red;">&#x1006;</i>#{/if}
                                                </p>
                                                <p>供货手续费：#{if $le.supplier == 1}#{$le.cost*100}%#{else}-#{/if}</p>
                                            </div>
                                        </a>
                                    #{/foreach}
                                </div>
                            </div>
                            <div style="margin-top: 10px;">
                                <blockquote class="elem-tips" style="font-size: 12px;">
                                    <p>• 分站返佣：开通分站后，您在分站售出的主站商品，将按差价返还佣金（实际成交金额 - 您的拿货价 = 您的佣金）。</p>
                                    <p>• 独立域名：开通分站后，您可绑定自己的顶级域名，而无需使用系统默认分配的子域名。</p>
                                    <p>• 供货权限：您可自建商品分类并上架商品进行销售，主站也将协助推广与售卖。</p>
                                    <p>• 供货手续费：针对您自主上架的商品，每笔成功交易将收取一定比例的手续费。</p>
                                </blockquote>

                            </div>
                            <div style="margin-top: 25px;">
                                <button type="button" class="layui-btn layui-btn-pink payButton">#{if !$business}立即开通
                                    #{/if}#{if $purchase == 1}立即升级#{/if}
                                </button>
                                #{if $purchase == 1}
                                    <a href="/user/business/index" class="layui-btn layui-btn-pink">返回店铺</a>
                                #{/if}
                            </div>
                        </div>
                    </form>
                #{else}
                    #{if $user.businessLevel.substation == 1}
                        <blockquote class="elem-quote">
                            当前商户等级：<img src="#{$user.businessLevel.icon}"
                                        style="height: 16px;margin-top: -4px;">#{$user.businessLevel.name}，绑定独立域名：#{if
                            $user.businessLevel.top_domain == 1}<b style="color: green;">✔</b>#{else}<b
                                style="color: red;">✖</b>#{/if}，供货权限：#{if
                            $user.businessLevel.supplier == 1}<b
                                style="color: green;">✔</b>，供货手续费：#{$user.businessLevel.cost*100}%#{else}<b
                                style="color: red;">✖</b>#{/if} #{if
                            count($level) > 0}
                                <a href="/user/business/index?purchase=1"
                                   style="color: #a372d7;font-weight: bold;margin-left: 10px;">我要升级，变得更强！</a>
                            #{/if}
                        </blockquote>
                        <form class="layui-form form-data">
                            <div>
                                <div class="form-header">店铺名称</div>
                                <div class="form-body"><input type="text" value="#{$business.shop_name}"
                                                              name="shop_name"
                                                              required autocomplete="off" placeholder="请输入店铺名称"
                                                              class="layui-input" style="color: #ff9191;"></div>
                            </div>
                            <div>
                                <div class="form-header">网站标题</div>
                                <div class="form-body"><input type="text" value="#{$business.title}" name="title"
                                                              required
                                                              autocomplete="off" placeholder="用于显示浏览器标题"
                                                              class="layui-input"
                                                              style="color: #ff9191;"></div>
                            </div>
                            <div>
                                <div class="form-header">店铺公告</div>
                                <div class="form-body">

                                    <div class="editor-wrapper">
                                        <div>
                                            <button data-type="0" class="button-switch-notice" type="button"
                                                    style="width: 100%;border: none;background: rgba(255, 255, 255, 0.35);border-radius: 5px 5px 0 0;color: #c9b8b8;">
                                                <i class="fa-duotone fa-regular fa-code me-1"></i>HTML
                                            </button>
                                        </div>
                                        <div class="editor-content">
                                            <div class="toolbar-container"></div>
                                            <div class="editor-container"></div>
                                        </div>
                                        <textarea class="text-container" style="display: none;"
                                                  name="notice"></textarea>
                                    </div>

                                </div>
                            </div>
                            <div>
                                <div class="form-header">显示主站商品[全局]</div>
                                <div class="form-body"><input type="checkbox" name="master_display" title="开启" value="1"
                                                              #{if
                                                              $business.master_display== 1}checked#{/if}>
                                </div>
                            </div>

                            <div>
                                <div class="form-header">主站分类
                                    <span class="a-badge a-badge-success category-show" data-state="1"
                                          style="cursor:pointer;">全部显示</span>
                                    <span class="a-badge a-badge-danger category-show" data-state="0"
                                          style="cursor:pointer;">全部隐藏</span>
                                </div>
                                <div class="form-body">
                                    <table id="master_category" lay-filter="master_category"></table>
                                </div>
                            </div>

                            <div>
                                <div class="form-header">主站商品
                                    <a id="commodity"></a>
                                    <span class="a-badge a-badge-success commodity-show" data-state="1"
                                          style="cursor:pointer;">全部显示</span>
                                    <span class="a-badge a-badge-danger commodity-show" data-state="0"
                                          style="cursor:pointer;">全部隐藏</span>

                                    <span class="a-badge a-badge-primary commodity-premium"
                                          style="cursor:pointer;">加价</span>
                                </div>
                                <div class="form-body">
                                    <table id="master_commodity" lay-filter="master_commodity"></table>
                                </div>
                            </div>
                            
                            <div>
                                <div class="form-header">子域名 #{if $business.subdomain}
                                        <i class="fa-duotone fa-regular fa-check text-success"></i>
                                        <a href="javascript:void(0);" class="unbind-subdomain text-success">解绑</a>
                                    #{/if}
                                </div>
                                <div class="form-body">
                                    <div class="layui-row" style="width: 400px;">
                                        <div class="layui-col-md5">
                                            <input type="text" value="#{$business.subdomain}" name="subdomain" required
                                                   autocomplete="off" placeholder="前缀" class="layui-input"
                                                   style="color: #ff9191;" #{if $business.subdomain} disabled #{/if}>
                                        </div>
                                        <div class="layui-col-md7">
                                            <select class="layui-select "
                                                    name="suffix" #{if $business.subdomain} disabled #{/if}>
                                                #{foreach $domain as $d}
                                                    <option value="#{$d}">.#{$d}</option>
                                                #{/foreach}
                                            </select>
                                        </div>
                                    </div>
                                </div>
                                #{if $user.businessLevel.top_domain == 1}
                                    <div>
                                        <div class="form-header">独立域名 #{if $business.topdomain}
                                                <a href="javascript:void(0);" class="unbind-topdomain text-success">解绑</a>
                                                [#{if gethostbyname($config.cname)
                                                == gethostbyname($business.topdomain)}
                                                    <b style="color: green;">正常</b>
                                                #{else}
                                                    <b style="color: mediumvioletred;">未检测到解析</b>
                                                #{/if}] #{/if} <span class="text-danger">CNAME解析地址：<b
                                                        style="color: green;">#{$config.cname}</b></span></div>
                                        <div class="form-body"><input type="text" value="#{$business.topdomain}"
                                                                      name="topdomain"
                                                                      required autocomplete="off" placeholder="绑定独立域名"
                                                                      class="layui-input"
                                                                      style="width:260px;color: #ff9191;" #{if
                                                    $business.topdomain} disabled #{/if}>
                                        </div>
                                    </div>
                                #{/if}
                                <div style="margin-top: 25px;">
                                    <button type="button" class="layui-btn layui-btn-pink save-config me-1">保存设置</button>
                                </div>
                        </form>
                    #{else}
                        <blockquote class="elem-quote">
                            您当前商户等级暂不支持店铺功能，<a href="/user/business/index?purchase=1">立即升级</a>
                        </blockquote>
                    #{/if}
                #{/if}
            </div>
        </div>
    </div>
</div>

#{ready("/assets/user/controller/business/business.js")}
#{include file="../Common/Footer.html"}
